package org.example;

import java.util.Scanner;

public class Test4
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while (true)
        {
            System.out.println("请输入被除数(>=0)");
            int a = sc.nextInt();
            System.out.println("请输入除数(>0)");
            int b = sc.nextInt();
            if (a >= 0 && b > 0)
            {
                int[] result = calculateShangAndYushu(a, b);
                System.out.println("商：" + result[0] + " 余数：" + result[1]);
                break;
            }
            else
            {
                System.out.println("error");
            }
        }
    }

    private static int[] calculateShangAndYushu(int a, int b)
    {
        int shang = 0;
        while (a >= b)
        {
            a -= b;
            shang++;
        }
        return new int[] {shang, a};
    }
}
